package com.xywy.beautyand.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


public class CalendarUtil {
	// ���ַ�ת��Ϊʱ���
	public static String getTime(String user_time) {
		String re_time = null;
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");//yyyy��MM��dd��HHʱmm��ss��
		Date d;
		try {
			d = sdf.parse(user_time);
			long l = d.getTime();
			String str = String.valueOf(l);
			re_time = str.substring(0, 9);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return re_time;
	}
	/**
	 * date convert timeStamp
	 * @param user_time
	 * @return
	 */
	
	public static String getTimeStamp(String user_time) {
		String re_time = null;
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//yyyy��MM��dd��HHʱmm��ss��
		Date date;
		try {
			date = sdf.parse(user_time);
			long l = date.getTime();
			re_time = l/1000+"";
//			String str = String.valueOf(l);
//			re_time = str.substring(0, 10);
			
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(re_time);
		return re_time;
	}
	/**
	 * timeStamp convert date
	 * @param user_time
	 * @return
	 */
	
	public static String getDate(String timestamp) {
		DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//yyyy��MM��dd��HHʱmm��ss��
		  long time= Long.parseLong(timestamp);
		  System.out.println(time);
           Date date = new Date(time);
	       String d = sdf.format(date);

	       System.out.println("Format To String(Date):"+d);

	       
		return d;
	}
	
	
	

	// ��ʱ���תΪ�ַ�
	public static String getStrTime(String cc_time) {
		String re_StrTime = null;
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy��MM��dd��HHʱmm��ss��");
		// ��cc_time=1291778220
		long lcc_time = Long.valueOf(cc_time);
		re_StrTime = sdf.format(new Date(lcc_time * 1000L));
		return re_StrTime;
	}
}
